//
//  SCAudioMediaPlayer.h
//  lg_zhinengbeikao_english
//
//  Created by Chao Sheng on 2021/12/20.
//  Copyright © 2021 zhukai. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN
typedef enum {
    SCAudioMediaStateUnknow = 0, //音频还未加载
    SCAudioMediaStatePlaying,
    SCAudioMediaStatePause,
    SCAudioMediaStateEnd,
    SCAudioMediaStateFail
} SCAudioMediaState;

typedef enum {
    SCAudioMediaStateBufferUnknow = 0, //音频缓冲未加载
    SCAudioMediaStateBuffering,  //音频正在缓冲
    SCAudioMediaStateBufferEnd  //缓冲结束
} SCAudioMediaBufferState;

/// 音频播放类
@interface SCAudioMediaPlayer : NSObject

/// 播放状态
@property (nonatomic, assign) SCAudioMediaState state;

/// 缓冲状态
@property (nonatomic, assign) SCAudioMediaBufferState bufferState;

/// 需要初始化不缓冲的，初始化init方法，需要加载时传入audioUrl的值
@property (nonatomic, copy) NSString *audioUrl;

/// 缓冲数据的回调
@property (nonatomic, copy) void (^scAudioBufferCallBack)(SCAudioMediaBufferState bufferState,CGFloat bufferTime,CGFloat totalTime);

/// 音频进度回调
@property (nonatomic, copy) void (^scAudioUpdateTimeCallBack)(SCAudioMediaState state,CGFloat currentTime,CGFloat totalTime);

- (void)play;

- (void)pause;

- (void)seekTime:(NSInteger)time;


/// 初始化播放器
/// @param rate 速率
- (instancetype)initWithRate:(CGFloat)rate;

/// 初始化播放器(传入audioUrl时，缓冲)
/// @param download 是否开启音频下载
//- (instancetype)initWithDownloadEnable:(BOOL)download completion:(void(^)(NSString *downloadPath))completion;

/// 初始化播放器(初始化就缓冲)
/// @param url 音频链接
- (instancetype)initWithAudioURL:(NSString*)url;

/// 初始化播放器(初始化就缓冲)
/// @param url 音频链接
/// @param rate 初始速率
- (instancetype)initWithAudioURL:(NSString*)url Rate:(CGFloat)rate;

@end

NS_ASSUME_NONNULL_END
